package com.dkm.ec.sale.repository.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.repository.AbstractRepository;
import com.dkm.ec.sale.domain.SaleSkuGroup;
import com.dkm.ec.sale.persistence.dao.SaleSkuGroupQueryDao;
import com.dkm.ec.sale.persistence.entity.SaleSkuGroupPo;
import com.dkm.ec.sale.repository.SaleSkuGroupRepository;

/**
 * 对象功能:销售产品SKU自定义组 Repository接口的实现类
 * 开发公司:SKG.COM
 * 开发人员:HJD
 * 创建时间:2015-07-08 17:38:34
 */
@Repository
public class SaleSkuGroupRepositoryImpl extends AbstractRepository<String, SaleSkuGroupPo,SaleSkuGroup> implements SaleSkuGroupRepository{
	  
	@Resource
	private  SaleSkuGroupQueryDao saleSkuGroupQueryDao;

	public SaleSkuGroup newInstance() {
		SaleSkuGroupPo po = new SaleSkuGroupPo();
		SaleSkuGroup saleSkuGroup = SpringHelper.getBean(SaleSkuGroup.class);
		saleSkuGroup.setData(po);
		return saleSkuGroup;
	}

	public SaleSkuGroup newInstance(SaleSkuGroupPo po) {
		SaleSkuGroup saleSkuGroup = SpringHelper.getBean(SaleSkuGroup.class);
		saleSkuGroup.setData(po);
		return saleSkuGroup;
	} 
	
	@Override
	protected IQueryDao<String, SaleSkuGroupPo> getQueryDao() {
		return saleSkuGroupQueryDao;
	}

	@Override
	public List<SaleSkuGroupPo> findGroups(Map<String, Object> params) {
		return saleSkuGroupQueryDao.findGroups(params);
	}

	@Override
	public List<SaleSkuGroupPo> findGroupsByGroupKey(Map<String, Object> params) {
		return saleSkuGroupQueryDao.findGroupsByGroupKey(params);
	}

	@Override
	public SaleSkuGroupPo findGroupByGroupKey(Map<String, Object> params) {
		return saleSkuGroupQueryDao.findGroupByGroupKey(params);
	}

	@Override
	public Integer countGroup() {
		return saleSkuGroupQueryDao.countGroup();
	}

	@Override
	public List<SaleSkuGroupPo> findAppointOptLists() {
		return saleSkuGroupQueryDao.findAppointOptLists();
	}

	/**
	 * 根据groupkey获取全部的组skuId
	 */
	@Override
	public List<SaleSkuGroupPo> findSkuGroupByKey(String skuGroup) {
		Map<String, Object> params = b().a("groupKey", skuGroup).p();
		return saleSkuGroupQueryDao.findByKey("findSkuGroupByKey", params);
	}
	
}
